home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-05-03 | 8.3 KB | 139 lines | [TEXT/KAHL] |
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // CHyperCuberPane.c
- //
- // This file contains the implementation of the pane for the graphic window.
- //___________________________________________________________________________
-
- #include "CControlsDirector.h"
- #include "CGraphic.h"
- #include "CHyperCuberApp.h"
- #include "CHyperCuberDoc.h"
- #include "CHyperCuberPane.h"
- #include "CHyperCuberPrefs.h"
- #include "CHyperScrollBar.h"
- #include "CRotateMouseTask.h"
- #include "HyperCuber Comman ths(&width, &height); // Find the new size of the pane
-
- Rect change_rect = {0, 0, 0, 0}; // Make pane fit the aspect ratio
- short size;
- if (width > aspect_ratio * height)
- {
- size = aspect_ratio * height;
- change_rect.right = size - width;
- }
- else
- {
- size = width;
- change_rect.bottom = size / aspect_ratio - height;
- }
-
- ChangeSize(&change_rect, FALSE);
- CenterWithinEnclosure(TRUE, TRUE);
-
- Rect bounds;
- LongToQDRect(&frame, &bounds); // Find size of pane
-
- adjust_offscreen_pixmap(&OffscreenPort, // Make offscreen bitmap large enough
- &bounds);
- graphic->FitToPane(); // Remap the graphic to the new pane size
-
- } //==== CHyperCuberPane::AdjustToEnclosure() ====\\
-
-
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // Procedure CHyperCuberPane::UpdateGraphicsPanes
- //
- // Purpose: Recompute and redraw the graphics pane
- //
- // Parameters: main_pane: the main pane
- //_________________________________________________________
-
- void CHyperCuberPane::UpdateGraphicsPanes(void)
- {
-
- LongRect graphics_rect;
- Prepare(); // Erase the pane
- GetFrame(&graphics_rect);
- LEraseRect(&graphics_rect);
-
- Rect no_movement = {0, 0, 0, 0};
- AdjustToEnclosure(&no_movement); // Recalc positions of graphics panes
-
- Refresh(); // Redraw the object
-
- } //==== CHyperCuberPane::UpdateGraphicsPanes() ====\\
-
-
- //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //| CHyperCuberPane::DoClick
- //|
- //| Purpose: This is called when the user clicks in the pane
- //|
- //| Parameters: hit_point: the point where the click occurred
- //| modifiers: modifiers from mouseDown event
- //| when: when the click occurred
- //|______________________________________________________________
-
- void CHyperCuberPane::DoClick(Point hit_point, short modifiers, long when)
- {
-
- Point global_point = hit_point;
- LocalToGlobal(&global_point); // Find click's global coordinates
- if (global_point.v < menubar_height)
- {
- DoCommand(cmdToggleMenuBar); // If the click was in the (hidden) menubar,
- return; // show the menubar.
- }
-
- mouse_task_struct h_mouse_tasks[MAX_MOUSE_CONTROLS];
- mouse_task_struct v_mouse_tasks[MAX_MOUSE_CONTROLS];
- short num_h_tasks = 0;
- short num_v_tasks = 0;
-
- CHyperCuberDoc *doc = (CHyperCuberDoc *) itsSupervisor; // Get the document
-
- long graphic_dimension = doc->graphic->dimension; // Find dimension of graphic
-
- long i;
- for (i = 0; i < gPrefs->prefs.num_mouse_controls; i++) // Loop through all mouse controls
- {
- mouse_control_struct mouse_control =
- gPrefs->prefs.mouse_controls[i]; // Get point to mouse controls
- if ((mouse_control.modifiers == modifiers) &&
- (mouse_control.dimension <= graphic_dimension)) // Use this task if the modifier keys
- // are right and the dimension is
- // no more than the graphic dimension
- {
-
- mouse_task_struct mouse_task;
-
- mouse_task.controls_director =
- (CControlsDirector *)
- doc->controls_directors->
- NthItem(mouse_control.dimension); // Find controls for this dimension
-
- mouse_task.angle = mouse_control.angle; // Get angle to change
- mouse_task.multiplier =
- mouse_control.multiplier; // Get multiplier
-
- if (mouse_control.horiz)
- h_mouse_tasks[num_h_tasks++] = mouse_task; // Add task to horizontal tasks array
-
- else
- v_mouse_tasks[num_v_tasks++] = mouse_task; // Add task to vertical tasks array
- }
- }
-
- CRotateMouseTask *mouse_task = new (CRotateMouseTask);
- mouse_task->IRotateMouseTask(this, h_mouse_tasks,
- v_mouse_tasks, num_h_tasks, num_v_tasks); // Initialize mouse task
-
- LongRect pin_rect = {-10000, -10000, 10000, 10000};
- LongPt long_hit_point;
- QDToLongPt(hit_point, &long_hit_point);
- TrackMouse(mouse_task, &long_hit_point, &pin_rect);
-
- } //==== CHyperCuberPane::DoClick() ====\\
-
-